package org.jeecg.modules.hc.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum HcSystemConfKeyEnum {
    MORNING_TIME_BEGIN("morning_time_begin", "上午倒计时开始时间"),
    MORNING_TIME_END("morning_time_end", "上午倒计时结束时间"),
    AFTERNOON_TIME_BEGIN("afternoon_time_begin", "下午倒计时开始时间"),
    AFTERNOON_TIME_END("afternoon_time_end", "下午倒计时结束时间"),
    ORDER_STATISTICS_TIME_BEGIN("order_statistics_time_begin", "统计订单开始时间"),
    ORDER_STATISTICS_TIME_END("order_statistics_time_end", "统计订单结束时间"),
    MERCHANT_ANNOUNCEMENT("merchant_announcement", "商户公告"),
    AMOUNT_OF_SHARED_CASH_BACK("amount_of_shared_cash_back", "分享返现金额"),
    ;

    @EnumValue
    private final String value;
    @JsonValue
    private final String name;

    HcSystemConfKeyEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    public static HcSystemConfKeyEnum get(String val) {
        Optional<HcSystemConfKeyEnum> first = Arrays.stream(HcSystemConfKeyEnum.values()).filter(e -> e.getValue().equals(val)).findFirst();
        return first.orElse(null);
    }

    public static HcSystemConfKeyEnum getByName(String name) {
        Optional<HcSystemConfKeyEnum> first = Arrays.stream(HcSystemConfKeyEnum.values()).filter(e -> e.getName().equals(name)).findFirst();
        return first.orElse(null);
    }
}
